<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OrderPrint extends BaseModel
{
    use HasFactory;
    protected $table = 'order_print';
    // 允许批量操作的字段
    protected $fillable = ['order_id','order_child_id','is_print','is_del','created_at','updated_at'];

    public function scopeSearch($query,$params)
    {
        if(!empty($params['order_id'])){
            $query->where('order_id',$params['order_id']);
        }
        $query->where('is_print',$params['is_print']??2);
        $query->where('is_del',$params['is_del']??2);
        return $query;
    }

    public function order_child(){
        return $this->hasOne(OrderChild::class,'id','order_child_id');
    }

}
